package br.com.rglariguet.pioneer.dao;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import br.com.rglariguet.pioneer.modelos.Peca;

@Repository
@Transactional
public class PecaDAO extends DaoGenerico<Peca> {

	public Peca buscaPorCodigo(String codigo) {
		return (Peca) getSession()
				.createQuery(
						"from Peca as peca where peca.codigo = :codigo")
				.setParameter("codigo", codigo).uniqueResult();
		
	}
	
	public List<Peca> listarTodos() {
		return (List<Peca>)getSession().createQuery("from Peca as peca order by peca.codigo").list();
	}
}
